import myReuquest from './index.js'
// 通过百度地图获取城市

function getUserCity(coordinate){
  const options = {
    url: "https://api.map.baidu.com/reverse_geocoding/v3/",
    data: {
      "ak": "",
      "output": "json",
      "coordtype": "wgs84ll",
      // "location":"31.225696563611, 121.49884033194"
    }
  }

  if (options.data.ak == "" || options.data.ak == undefined){
    console.log('请在/network/home.js中配置百度地图ak')
    throw Error('请在/network/home.js中配置百度地图ak')
  }

  options.data.location = coordinate
  return myReuquest(options)
}
// 通过豆瓣api获取正在上映的电影

function getDoubanData({city=null,url=null,count=null,start=null}={}) {
  const options = {
    url: "https://douban.uieee.com",
    // 备用url
    // url: "https://douban-api.uieee.com",
    
    // 豆瓣屏蔽了小程序所以需要请求头
    header: { "content-type": 'json' },
    data: {}
  }
  city && (options.data.city = city)
  url && (options.url = `${options.url}${url}` )
  count && (options.data.count = count)
  start && (options.data.start = start)
  return myReuquest(options)
}
export {
  getUserCity,
  getDoubanData
}